#!/bin/bash

echo "🚀 TZAI Flutter 快速启动脚本"
echo "=============================="
echo ""

# 检查 Flutter
if ! command -v flutter &> /dev/null; then
    echo "❌ Flutter 未安装，请先安装 Flutter SDK"
    exit 1
fi

echo "✅ Flutter 版本:"
flutter --version | head -n 1

echo ""
echo "📦 安装依赖..."
flutter pub get

echo ""
echo "📱 可用设备列表:"
flutter devices

echo ""
echo "🔧 选择运行方式:"
echo "1. 自动选择设备运行"
echo "2. 指定设备 ID 运行"
echo "3. 仅检查代码（flutter analyze）"
echo ""
read -p "请输入选项 (1-3): " choice

case $choice in
    1)
        echo ""
        echo "🏃 启动应用..."
        flutter run
        ;;
    2)
        echo ""
        read -p "请输入设备 ID: " device_id
        echo "🏃 在设备 $device_id 上启动应用..."
        flutter run -d "$device_id"
        ;;
    3)
        echo ""
        echo "🔍 代码检查中..."
        flutter analyze
        ;;
    *)
        echo "❌ 无效选项"
        exit 1
        ;;
esac
